 //
//  Account.m
//  微博2期
//
//  Created by J on 15/11/27.
//
//

#import "Account.h"

@implementation Account

+ (instancetype)accountWithDic:(NSDictionary*)dic{
    
    Account * account= [[self alloc]init];
    account.access_token = dic[@"access_token"];
    account.expires_in = dic[@"expires_in"];
    account.uid = dic[@"uid"];
    account.create_time = [NSDate date];


    return account;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder{//从沙盒中接档一个对象(从沙盒中加载一个对象时)调用这个方法
//目的:需要取出哪些属性
    
    if (self = [super init]) {
        //获得帐号存储时间
        self.access_token = [aDecoder decodeObjectForKey:@"access_token"];
        self.expires_in = [aDecoder decodeObjectForKey:@"expires_in"];
        self.uid = [aDecoder decodeObjectForKey:@"uid"];
        self.create_time = [aDecoder decodeObjectForKey:@"create_time"];
        self.name = [aDecoder decodeObjectForKey:@"name"];

    }
    
    return self;
    
}
- (void)encodeWithCoder:(NSCoder *)aCoder{//当一个对象要归档进沙盒时 调用 在这个方法中说明这个对象的哪些属性要存进沙盒
    
    [aCoder encodeObject:self.access_token forKey:@"access_token"];
    [aCoder encodeObject:self.expires_in forKey:@"expires_in"];
    [aCoder encodeObject:self.uid forKey:@"uid"];
    [aCoder encodeObject:self.create_time forKey:@"create_time"];
    [aCoder encodeObject:self.name forKey:@"name"];

    
}

@end
